<%@ page import="java.util.List" %>
<%@ page import="com.qf.pojo.Emp" %><%--
  Created by IntelliJ IDEA.
  com.qf.pojo.User: sun
  Date: 2022/9/7
  Time: 11:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>员工列表</title>
</head>
<body>
当前在线人数: ${applicationScope.count}
<table align="center" border="1" cellspacing="0" bordercolor="red" cellpadding="5">
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>工资</th>
        <th>年龄</th>
        <th>操作</th>
    </tr>
    <c:if test="${empty pageBean.data}">
        <tr>
            <td colspan="5">员工列表为空</td>
        </tr>
    </c:if>
    <c:forEach var="e" items="${requestScope.pageBean.data}">
        <tr>
            <td>${e.id}</td>
            <td>${e.name}</td>
            <td>${e.salary}</td>
            <td>${e.age}</td>
            <td>
                <a href="/deleteEmp?id=${e.id}">删除</a>
                <a href="/selectOneEmp?id=${e.id}">修改</a>
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="5">
            <c:if test="${pageBean.pageNum != 1}">
                <a href="/selectAllEmp?pageNum=1">首页</a>
            </c:if>

            <c:choose>
                <c:when test="${pageBean.pageNum == 1}">
                    上一页
                </c:when>
                <c:otherwise>
                    <a href="/selectAllEmp?pageNum=${pageBean.pageNum - 1}">上一页</a>
                </c:otherwise>
            </c:choose>
             <c:forEach var="i" begin="1" end="${pageBean.totalPage}">
                 <c:choose>
                     <c:when test="${pageBean.pageNum == i}">
                         <b>${i}</b>
                     </c:when>
                     <c:otherwise>
                         <a href="/selectAllEmp?pageNum=${i}">${i}</a>
                     </c:otherwise>
                 </c:choose>

             </c:forEach>
            <c:choose>
                <c:when test="${pageBean.pageNum == pageBean.totalPage}">
                    下一页
                </c:when>
                <c:otherwise>
                    <a href="/selectAllEmp?pageNum=${pageBean.pageNum + 1}">下一页</a>
                </c:otherwise>
            </c:choose>
            <c:if test="${pageBean.pageNum != pageBean.totalPage}">
                <a href="/selectAllEmp?pageNum=${pageBean.totalPage}">尾页</a>
            </c:if>
        </td>
    </tr>
</table>

</body>
</html>
